<template>
    <container type="top-header" :show="{header:formShow}" class="g-width100 g-height100" header-style="height:auto;" main-style="padding:0;">
        <Form slot="header" inline
              submit-bus-key="EstateManageList"
              :form-items="formItems"
              :layout="[3,4,3]" :layout-col-max="6"
              label-width="100px"
        ></Form>
        <Table slot="main"
               ref="table"
               form-submit-bus-key="EstateManageList"
               :columns="columns"
               :operations="tableOperations"
               unique-label="name"
               v-on:toolbarSearchClick="formShow = !formShow"
        ></Table>
    </container>
</template>

<script>
    import Container from '../../../../common-util/src/components/page/Container.vue'
    import Form from '../../../../common-util/src/components/page/Form.vue'
    import Table from '../../../../common-util/src/components/page/Table.vue'

    export default {
        components:{
            Form,
            Table,
            Container
        },
        data(){
            return {
                formShow: true,
                formItems:[
                    {
                        field: {
                            name: 'code'
                        },
                        element:{
                            label: '编号',
                        }
                    },
                    {
                        field: {
                            name: 'name'
                        },
                        element:{
                            label: '名称',
                        }
                    },
                    {
                        field: {
                            name: 'nameAlias'
                        },
                        element:{
                            label: '名称别名',
                        }
                    },
                    {
                        field: {
                            name: 'provinceAreaId'
                        },
                        element:{
                            label: '省',
                            type: 'select',
                            select: {
                                url: this.$baseURL.base + '/base/area/list?parentCode=country_zhongguo&typeDictCode=province'
                            }
                        }
                    },
                    {
                        field: {
                            name: 'cityAreaId'
                        },
                        element:{
                            label: '城市',
                            disabled: (form)=>{
                                return !form.provinceAreaId
                            },
                            type: 'select',
                            select: {
                                url: (form)=>{
                                    if (!form.provinceAreaId) {
                                        return null
                                    }
                                    return this.$baseURL.base + '/base/area/list?parentId=' + form.provinceAreaId
                                }
                            }
                        }
                    },
                    {
                        field: {
                            name: 'districtAreaId'
                        },
                        element:{
                            label: '区',
                            disabled: (form)=>{
                                return !form.cityAreaId
                            },
                            type: 'select',
                            select: {
                                url: (form)=>{
                                    if (!form.cityAreaId) {
                                        return null
                                    }
                                    return this.$baseURL.base + '/base/area/list?parentId=' + form.cityAreaId
                                }
                            }
                        }
                    },
                    {
                        field: {
                            name: 'businessDistrictId'
                        },
                        element:{
                            label: '商圈',
                            disabled: (form)=>{
                                return !form.districtAreaId
                            },
                            type: 'select',
                            select: {
                                url: (form)=>{
                                    if (!form.districtAreaId) {
                                        return null
                                    }
                                    return this.$baseURL.composite + '/composite/businessdistrict/list?districtAreaId=' + form.districtAreaId
                                }
                            }
                        }
                    },
                    {
                        field: {
                            name: 'developerCompanyId'
                        },
                        element:{
                            type: 'selectRemote',
                            selectRemote:{
                                url: this.$baseURL.crm + '/crm/company/listPage',
                            },
                            label: '开发商公司',
                        }
                    },
                    {
                        field: {
                            name: 'propertyCompanyId'
                        },
                        element:{
                            type: 'selectRemote',
                            selectRemote:{
                                url: this.$baseURL.crm + '/crm/company/listPage',
                            },
                            label: '物业公司',
                        }
                    },
                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'get',
                                    url: this.$baseURL.house + '/house/estate/listPage',
                                    label: '查询'
                                },
                                {
                                    action: 'reset',
                                    label: '重置'
                                }
                            ]
                        }
                    }
                ],
                columns:[
                    {
                        prop: 'code',
                        label:'编号'
                    },
                    {
                        prop: 'name',
                        label:'名称'
                    },
                    {
                        prop: 'nameAlias',
                        label:'名称别名',
                        showInDetail: true
                    },
                    {
                        prop: 'spellFirst',
                        label:'首字母',
                        showInDetail: true
                    },
                    {
                        prop: 'spellSimple',
                        label:'简拼',
                        showInDetail: true
                    },
                    {
                        prop: 'spell',
                        label:'全拼'
                    },
                    {
                        prop: 'longitude',
                        label:'经度',
                        showInDetail: true
                    },
                    {
                        prop: 'latitude',
                        label:'纬度',
                        showInDetail: true
                    },
                    {
                        prop: 'provinceAreaName',
                        label:'省'
                    },
                    {
                        prop: 'cityAreaName',
                        label:'城市'
                    },
                    {
                        prop: 'districtAreaName',
                        label:'区'
                    },
                    {
                        prop: 'businessDistrictName',
                        label:'商圈'
                    },
                    {
                        prop: 'address',
                        label:'地址全名',
                        showInDetail: true
                    },
                    {
                        prop: 'addressAlias',
                        label:'地址别名',
                        showInDetail: true
                    },
                    {
                        prop: 'coverImageUrl',
                        label:'封面图',
                        formatType: 'image'
                    },
                    {
                        prop: 'coverArea',
                        label:'占地面积',
                        showInDetail: true
                    },
                    {
                        prop: 'buildingArea',
                        label:'建筑面积',
                        showInDetail: true
                    },
                    {
                        prop: 'plotRatio',
                        label:'容积率'
                    },
                    {
                        prop: 'greenRatio',
                        label:'绿化率'
                    },
                    {
                        prop: 'aboveGroundParkingSpaceNum',
                        label:'地上车位数',
                        showInDetail: true
                    },
                    {
                        prop: 'belowGroundParkingSpaceNum',
                        label:'地下车位数',
                        showInDetail: true
                    },
                    {
                        prop: 'parkingRatio',
                        label:'车位占比',
                        showInDetail: true
                    },
                    {
                        prop: 'areaMin',
                        label:'面积区间最小值',
                        showInDetail: true
                    },
                    {
                        prop: 'areaMax',
                        label:'面积区间最大值',
                        showInDetail: true
                    },
                    {
                        prop: 'isHasYs',
                        label:'是否有一手销售',
                        showInDetail: true
                    },
                    {
                        prop: 'isHasErs',
                        label:'是否有二手销售',
                        showInDetail: true
                    },
                    {
                        prop: 'isHasZu',
                        label:'是否有租房',
                        showInDetail: true
                    },
                    {
                        prop: 'buildAtTxt',
                        label:'始建于',
                        showInDetail: true
                    },
                    {
                        prop: 'builtAtTxt',
                        label:'建成于',
                        showInDetail: true
                    },
                    {
                        prop: 'developerCompanyName',
                        label:'开发商公司',
                        showInDetail: true
                    },
                    {
                        prop: 'propertyCompanyName',
                        label:'物业公司',
                        showInDetail: true
                    },
                    {
                        prop: 'loopLineDictName',
                        label:'环线位置',
                        showInDetail: true
                    },
                ],
                tableOperations:[
                    {
                        action: 'nav',
                        url:'/estate/estateAdd',
                        label: '添加'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/estate/estateEdit/:id',
                        label: '编辑'
                    },
                    {
                        action: 'detail',
                        disabledOnMissingSelect:true,
                        label: '详情'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/estatePhaseNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.id,
                                estateName: row.name
                            }
                        },
                        label: '分期管理'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/estateAlbumNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.id,
                                estateName: row.name
                            }
                        },
                        label: '相册管理'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/estateApartmentLayoutNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.id,
                                estateName: row.name
                            }
                        },
                        label: '户型管理'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/estateLicenceNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.id,
                                estateName: row.name
                            }
                        },
                        label: '五证管理'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/buildingNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.id,
                                estateName: row.name
                            }
                        },
                        label: '楼栋管理'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/estateNearbyFeatureNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.id,
                                estateName: row.name
                            }
                        },
                        label: '周边管理'
                    },
                    {
                        action: 'delete',
                        url:this.$baseURL.house + '/house/estate/:id',
                        disabledOnMissingSelect:true,
                        label:'删除'
                    }
                ]
            }
        }
    }
</script>

<style scoped>

</style>